# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=vulkan
pkgbase=mingw-w64-${_realname}-docs
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}-docs")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}-html-docs" "${MINGW_PACKAGE_PREFIX}-${_realname}-man-pages")
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-html-docs" "${MINGW_PACKAGE_PREFIX}-${_realname}-man-pages")
_pkgname=Vulkan-Docs
pkgver=1.0.51
_pkgver=${pkgver}-core
pkgrel=1
arch=('any')
url="https://www.khronos.org/vulkan/"
groups=("${MINGW_PACKAGE_PREFIX}-vulkan-devel")
makedepends=("${MINGW_PACKAGE_PREFIX}-asciidoctor" "${MINGW_PACKAGE_PREFIX}-python3")
license=('custom')
source=(${_realname}-docs-${_pkgver}.tar.gz::"https://github.com/KhronosGroup/${_pkgname}/archive/v${_pkgver}.tar.gz"
        remove-pdf-generating.patch)
sha256sums=('64e5ef8e4a34de6c3723648d1993f111cb2d6edb533dab4f5dd55d974083f4a7'
            'eecad38d283a165129d9bafcd5ebbd481e7b9036cf3a37815e2de3cef1b01aff')

prepare() {
  cd ${_pkgname}-${pkgver}-core
  patch -p1 -i ${srcdir}/remove-pdf-generating.patch
}

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}-core/doc/specs/vulkan"
  LANG="en_US.UTF8" make allman
  ./makeKHR
}

package() {
  pkgdesc="Vulkan documentation (mingw-w64)"
  cd "${srcdir}/${_pkgname}-${pkgver}-core"
  install -dm755 "${pkgdir}${MINGW_PREFIX}/share/doc/vulkan"
  install -dm755 "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-docs"

  mv -v out/1.0/* "${pkgdir}${MINGW_PREFIX}/share/doc/vulkan/"

  install -m644 doc/specs/vulkan/copyright-ccby.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-docs/copyright-ccby.txt
  install -m644 doc/specs/vulkan/copyright-spec.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}-docs/copyright-spec.txt
}
